﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Sparkle.Lib;

namespace Sparkle.UI.Utility
{
    public class OtherExtra
    {

        /// <summary>
        /// enum class not woking in Sl
        /// </summary>
        /// <param name="enumeration"></param>
        /// <returns></returns>
        public static string[] GetNames(Type enumeration)
        {
            List<string> names = new List<string>();
            FieldInfo[] infoCollection = enumeration.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo fi in infoCollection)
            {
                names.Add(fi.Name);
            }
            return names.ToArray();
        }

        public static Dictionary<string, object> GetEnumCollection(Type enumeration)
        {
            Dictionary<string, object> namesList = new Dictionary<string, object>();
            FieldInfo[] infoCollection = enumeration.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo fi in infoCollection)
            {
                namesList.Add(fi.Name, Enum.Parse(enumeration, fi.Name, true));
            }
            return namesList;
        }

    }

    public static class UIExtensions
    {
        public static void UpdateLookup(this ILookup lookup, bool forceToUpdate)
        {
            if (lookup != null && (forceToUpdate || lookup.GetValidList().Count == 0))
            {
                //lookup.GetType().Attributes
            }
        }
    }
}
